//
//  YTStashLeftTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/5.
//

#import "YTStashLeftTableViewCell.h"

@interface YTStashLeftTableViewCell()
@property (nonatomic ,strong) UIImageView * img;
@property (nonatomic ,strong) UILabel * lab;
@property (nonatomic ,strong) UIView * line;
@property (nonatomic ,strong) UIView * makeview;

@end

@implementation YTStashLeftTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * makeview = [UIView new];
    self.makeview = makeview;
    makeview.backgroundColor = KcolorHex(@"#F0F0F0");
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.offset(0);
    }];
    
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#0567FC");
    self.line = line;
    [makeview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.width.offset(kwt(4));
        make.height.offset(kwt(44));
        make.centerY.offset(0);
    }];
    
    
    UIImageView * img = kimageView(@"temp");
    self.img = img;
    [makeview addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(17));
        make.width.height.offset(kwt(15));
        make.centerY.offset(0);
    }];
    
    UILabel * lab = [DTKTool labelWithText:@"--" andFont:kFont(18) andTextColor:KcolorHex(@"#222222")];
    self.lab = lab;
    [makeview addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(34));
        make.right.offset(kwt(-5));
        make.centerY.offset(0);
    }];
    
}

- (void)setModel:(YTStashLeftModel *)model{
    _model = model;
    self.lab.text = model.name;
    self.lab.textColor = model.isSeled?KcolorHex(@"#0567FC"):KcolorHex(@"#222222");
    self.img.image = [UIImage imageNamed:model.icon];
    self.line.hidden = !model.isSeled;
    self.makeview.backgroundColor = model.isSeled?UIColor.whiteColor:KcolorHex(@"#F0F0F0");
    
}
@end
